package eleanor.ltd.isRealEstate.dao.user.group;

import java.util.List;

import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import eleanor.ltd.isRealEstate.entities.user.User;
import eleanor.ltd.isRealEstate.entities.user.group.UserGroup;


public class UserGroupDAOImpl implements UserGroupDAO {

	@Inject
	private Session session;

	@Log
	public String findAdministrator(Long id) {
		// TODO Auto-generated method stub
		String temp = "";
		System.out.println("Prije liste");
		List l = session.createCriteria(UserGroup.class).add(Restrictions.eq("uid", id)).list();
		System.out.println("Posle liste");
		UserGroup ug = null;
		if (l != null) {
			if (l.size() > 0) {
				ug = (UserGroup) l.get(0);
				
				temp = ug.getRolesGroup().getRoles().getRoleName().toString();
				return temp;
			}
		}
		return "BLA BLA BLA BLA";
	}
	
	
	
}
